/*
  File name: list.c

  This file contains code for a linked-list implementation.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "list.h"

struct node {
    char *data;
    struct node *next;
};

/* return the result of "adding" an element to the front of the given list */
struct node *add(char *newFirst, struct node *list)
{
    struct node *newNode = (struct node *) malloc(sizeof(struct node));
    newNode->data = (char *) malloc(sizeof(strlen(newFirst)));
    strcpy(newNode->data, newFirst);
    newNode->next = list;
    //    return newNode;
    
}

/* return an empty list */
struct node *emptyList()
{
    return NULL;
}

/* determine if a list is empty */
int isEmpty(struct node *list)
{
    return list == NULL;
}

/* return the first element of the given list */
char *first(struct node *list)
{
    return list->data;
}

/* return the rest of the given list (all elements after the first) */
struct node *rest(struct node *list)
{
    return list->next;
}
